package com.freight.order.controller;

import com.freight.core.common.utils.PageUtil;
import com.freight.core.common.utils.ResultUtil;
import com.freight.core.common.vo.PageVo;
import com.freight.core.common.vo.Result;
import com.freight.core.common.vo.SearchVo;
import com.freight.order.dto.OrderExtendDto;
import com.freight.order.entity.OrderExtend;
import com.freight.order.service.OrderExtendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huyingtai
 */
@Slf4j
@RestController
@Api(description = "司机端 --- 装货、卸货接口")
@RequestMapping("/freight/orderExtend")
public class OrderExtendController   {

    @Autowired
    private OrderExtendService orderExtendService;


    @RequestMapping(value = "/getByCondition", method = RequestMethod.GET)
    @ApiOperation(value = "平台端 --- 管理后台首页")
    public Result<Page<OrderExtend>> getByCondition(OrderExtend orderExtend, SearchVo searchVo, PageVo pageVo) {
        Page<OrderExtend> page = orderExtendService.findByCondition(orderExtend, searchVo, PageUtil.initPage(pageVo));
        return new ResultUtil<Page<OrderExtend>>().setData(page);
    }

    @RequestMapping(value = "/saveOrderExtend", method = RequestMethod.POST)
    @ApiOperation(value = "司机端 --- 货物装货")
    public Result<String> saveOrderExtend(OrderExtendDto orderExtendDto) {
        orderExtendService.saveOrderExtend(orderExtendDto);
        return new ResultUtil<String>().setData("操作成功");
    }

    @RequestMapping(value = "/updateOrderExtend", method = RequestMethod.POST)
    @ApiOperation(value = "司机端 --- 货物卸货")
    public Result<String> updateOrderExtend(OrderExtendDto orderExtendDto) {
        orderExtendService.updateOrderExtend(orderExtendDto);
        return new ResultUtil<String>().setData("操作成功");
    }

}
